package com.atguigu.gateway.api.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
//@Component
public class GlobalGatewayFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("..................");
        System.out.println(exchange.getRequest().getHeaders().getHost().toString());
//        HttpHeaders headers = exchange.getRequest().getHeaders();
//        headers.
        System.out.println("exchange.getRequest().getHeaders().getHost().getHostString() = " + exchange.getRequest().getHeaders().getHost().getHostString());
        System.out.println("exchange.getRequest().getHeaders().getHost().getHostString() = " + exchange.getRequest().getHeaders().getHost().getAddress());
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
